$(function(){
    books=JSON.parse(localStorage.getItem("books"));
    layui.use(['laypage', 'layer'], function(){
        var laypage = layui.laypage
        ,layer = layui.layer;
            laypage.render({
                elem: 'demo20',
                limit:books.length/2
                ,count: books.length
                ,jump: function(obj){
                //模拟渲染
                document.getElementById('show').innerHTML = function(){
                    var arr = []
                    ,thisData = books.concat().splice(obj.curr*obj.limit - obj.limit, obj.limit);
                        layui.each(thisData, function(index, item){
                            console.log(item);
                        arr.push(' <div class="showImgWord">'+
                                        '<img src="imgs/books/'+item.img+'" alt="">'+
                                        '<div class="word">'+
                                            '<div id="word0">'+
                                            '<p>'+item.desc+'</p>'+
                                            '</div>'+
                                            '<p class="buy"><span class="price">团购价'+item.newPrice+'</span><span class="linethrouth">'+item.oldPrice+'</span>'+
                                            '<input class="layui-btn layui-btn-sm layui-btn-normal " type="button" value="'+(((item.newPrice)/(item.oldPrice))*10).toFixed(1)+'折">'+
                                            '</p>'+
                                        '</div>'+
                                    '</div>')
                        });
                    return arr.join('');
                }();
                }
            });
        });
    });